import Vue from 'vue'
import App from './App'

Vue.config.productionTip = false

// vuex
import store from './store'
Vue.prototype.$store = store

//http
import { http } from '@/util/http.js'
Vue.prototype.$http = http
//配置参数
import config from '@/common/config.js'
Vue.prototype.$config = config

//ws
import * as socketApi from './common/wssocket';
Vue.prototype.$wsApi = socketApi;
// 引入全局uView
import uView from '@/uni_modules/uview-ui'
App.mpType = 'app'
Vue.use(uView)
import moment from 'moment'
//  全局过滤器 时间戳 
Vue.filter('dateformat', function (dataStr, pattern = 'yyyy-MM-DD  HH-mm') {
  if (dataStr) {
    return moment(dataStr).format(pattern)
  } else {
    return dataStr
  }
})
// 创建全局定时方法对象
const globalInterval = {
  timer: null,
  start(callback, interval) {
    this.stop(); // 确保先停止任何现有的定时器
    this.timer = setInterval(callback, interval);
  },
  stop() {
    if (this.timer) {
      clearInterval(this.timer);
      this.timer = null;
    }
  }
};

// 将全局定时方法挂载到 Vue 原型上
Vue.prototype.$globalInterval = globalInterval;
const app = new Vue({
    store,
    ...App
})


// 引入请求封装
require('./util/request/index')(app)

app.$mount()
